package com.box.app.arithmetic

import kotlin.math.pow

actual operator fun Number.plus(other: Number): Number = toDouble() + other.toDouble()

actual operator fun Number.minus(other: Number): Number = toDouble() - other.toDouble()

actual operator fun Number.times(other: Number): Number = toDouble() * other.toDouble()

actual operator fun Number.div(other: Number): Number = toDouble() / other.toDouble()

actual operator fun Number.rem(other: Number): Number = toDouble() % other.toDouble()

actual operator fun Number.unaryMinus(): Number = toDouble().unaryMinus()

actual operator fun Number.inc(): Number = toDouble().inc()

actual operator fun Number.dec(): Number = toDouble().dec()

actual operator fun Number.inv(): Number = toLong().inv()

actual fun Number.plus(): Number = toDouble()

actual fun Number.negate(): Number = -toDouble()

actual fun Number.pow(a: Number): Number = toDouble().pow(x = a.toDouble())

actual fun Number.and(a: Number): Number = toLong().and(a.toLong())

actual fun Number.or(a: Number): Number = toLong().or(a.toLong())

actual fun Number.xor(a: Number): Number = toLong().xor(a.toLong())

actual fun Number.shl(a: Number): Number = toLong().shl(a.toInt())

actual fun Number.shr(a: Number): Number = toLong().shr(a.toInt())

actual fun Number.ushr(a: Number): Number = toLong().ushr(a.toInt())

actual fun String.toNumberOrNull(): Number? = toDoubleOrNull()